<?php

defined('In33hao') or exit('Access Invalid!');

class auto_storeControl extends SystemControl{

    public function __construct(){
        parent::__construct();
    }

    public function indexOp(){
           $this->auto_storelist();
    }

    // 开店列表
    public function auto_storelist(){

           Tpl::setDirquna('shop');
           Tpl::showpage("auto_storelist");
    }

    public function storelistOp(){
        $model_class = Model('goods_class');
        $condition['isshow'] = 0;
        $goods_class = $model_class->getGoodsClassList($condition,'gc_id');
        $gc_idstr = '';
        foreach($goods_class as $k => $v){
            $gc_idstr .= $v['gc_id'].',';
        }
        $where['gc_id'] = array('in',trim($gc_idstr,','));
        $resulte = Model('order_goods')->where($where)->select();
        foreach($resulte as $key => $value){
            $resulte[$key]['member'] = Model('member')->getMemberInfo(array('member_id'=>$value['buyer_id']),'member_name,member_id');
        }
        $page   = new Page();
        $page->setEachNum($_POST['rp']);

        $data = array();
        $data['now_page'] = $page->get('now_page');
        $data['total_num'] = $page->get('total_num');
        foreach((array)$resulte as $val) {
            $param = array();
            $operation = "<a class='btn red' href='javascript:void(0);' onclick='fg_del(" . $val['member']['member_id'] . ")'><i class='fa fa-trash-o'></i>删除</a>";
            $param['operation'] = $operation;
            $param['goods_id'] = $val['goods_id'];
            $param['member_name'] = $val['member']['member_name'];
            $param['goods_name'] = $val['goods_name'];
            $data['list'][$val['goods_id']] = $param;
        }
        echo Tpl::flexigridXML($data);exit();
    }
}